﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Model;
using LitJson;
using System.IO;

namespace Model
{
    public static class JsonHelper
    {
        /// <summary>
        /// 将指定目录的json文件读取到指定数据对象中
        /// </summary>
        /// <typeparam name="T">读取的最外层级</typeparam>
        /// <typeparam name="K">读取的次级层级等内容</typeparam>
        /// <param name="path"></param>
        public static T Readconfig<T>(string path)
        {
            StreamReader json = new StreamReader(path);
            string _input = json.ReadToEnd();
            json.Close();
            return JsonMapper.ToObject<T>(_input);
        }

        public static T Readconfig<T>(TextAsset data)
        {
            return JsonMapper.ToObject<T>(data.text);
        }
    }
}

